package cn.com.lms.business.exam.persistence.entity;

import com.bnzj.core.persistence.entity.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.Date;
import java.util.List;

@Getter
@Setter
@Entity
@Table(name = "bnz_exam_question_subject")
@Schema(description = "试题")
public class QuestionSubject extends BaseEntity {

    @Schema(description = "题库ID")
    @Column(name = "question_id")
    private Long questionId;

    @Schema(description = "题型 1-单选题 2-多选题 3判断题 4填空题 5问答题")
    private Short type;

    @Schema(description = "题目")
    private String subject;

    @Schema(description = "批阅状态 0-不批阅 1-按序批阅 2-无序批阅")
    @Column(name = "correct_status")
    private Short correctStatus;


    @Schema(description = "是否删除  0-未删除 1-已删除")
    @Column(name = "is_delete")
    private Boolean isDelete;


    @Schema(description = "答案解析")
    @Transient
    private String parse;

    @Schema(description = "题目图片")
    @Transient
    List<QuestionSubjectFile> questionSubjectFileList;


    @Transient
    @Schema(description = "选择题选项")
    List<QuestionSubjectOption> questionSubjectOptionList;


    @Transient
    @Schema(description = "判断题选项")
    Boolean isRight;


    @Transient
    @Schema(description = "填空题答案项")
    List<QuestionSubjectFill> questionSubjectFillList;

    @Transient
    @Schema(description = "问答题答案")
    private String answer;


    public QuestionSubject() {
        if (this.getCreator() == null) this.setCreator("10000000");
        if (this.getCreateTime() == null) this.setCreateTime(new Date());
        if (this.getCreatorName() == null) this.setCreatorName("admin");
        if (this.getIsDelete() == null) this.setIsDelete(false);
        if (this.getParse() == null) this.setParse("");
        if (this.getCorrectStatus() == null) this.setCorrectStatus(Short.valueOf("0"));

    }
}
